﻿CREATE FUNCTION [dbo].[fn_ColumnDefaultConstraint]
(
	@Table   sysname,
	@Column  sysname
)
RETURNS sysname
AS
BEGIN
	RETURN (
	    SELECT dc.[name]
	    FROM   sys.[columns] c
	           INNER JOIN sys.tables t
	                ON  t.[object_id] = c.object_id
	           INNER JOIN sys.default_constraints dc
	                ON  dc.parent_object_id = c.object_id
	                AND dc.parent_column_id = c.column_id
	    WHERE  t.[name] = @Table
	           AND c.[name] = @Column
	           AND t.[type] = 'U'
	)
END